#ifndef _TELFileRaw
#define _TELFileRaw

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;

#include<TROOT.h>
#include<TTree.h>
#include<TMath.h>
#include<TLine.h>

#include<Global.h>
#include<TELAlign.h>

#define EventLength 1280*3 + 20 + 256 + 10
#define Xstrip 1950
#define Ystrip 1950
#define NumOfChan 1280
#define NumOfSil 3
#define BuffSize NumOfChan*NumOfSil


class TELFileRaw{
	Int_t Private;
////////////////////////////
	Int_t RunNumber;
  	Int_t num_events;
  	//vector < vector <Int_t>  > ADCDataX;
  	//vector < vector <Int_t>  > ADCDataY;
  	int ** ADCDataX;
  	int ** petya;
  	Int_t ** SumX;
  	Int_t ** SumY;

  	typedef int * intptr;

  	unsigned int EVENT[BuffSize + 8];

	unsigned char temp_bit[5000];
	unsigned char tmp_bit;


  //Int_t ADCDataX[2000][1000];
  //Int_t ADCDataY[2000][1000];

 //ADCDataX[0].push_back();
////////////////////////////
  Global* glob;

  const Char_t* SiFilePath;
  FILE* SiFile;
  FILE* ConvFile;

  Double_t Trigger[2];
  Char_t Path[200];
  //Char_t DataFileName[20];

  Float_t* PedX2 ;
  Float_t* NormX ;
  Float_t* PedY2 ;
  Float_t* NormY ;

  Int_t ADCXSize;
  Int_t* PlaneXADC;
  Int_t ADCYSize;
  Int_t* PlaneYADC;
  Int_t* ShiftX;
  Int_t* ShiftY;

  Float_t* PedX;
  Float_t* PedY;
  Float_t* NoiX;
  Float_t* NoiY;
  //Float_t PedX;
  //Float_t PedY;
  //Float_t NoiX;
  //Float_t NoiY;

  Char_t* TELRoot;
  TFile* TELData;
  TTree* TELTree;

  TELAlign* PreAlignment;
  Double_t* APara;

 public:
  TELFileRaw(Int_t);
  void PlugConverter(void);
  Int_t OpenConvertFile(Int_t);
  Int_t OpenFile(Int_t);
  void ReadEvents(void);
  void Variables(void);
  void SimplePedNoiRaw(void);
  void SumDataX(Int_t, Int_t);
  void SumDataY(Int_t, Int_t);
  Int_t swap4Raw(Int_t w4);

  //~TELFileRaw();

  //Int_t ReadEventsRaw();
  //Int_t swap4Raw(Int_t w4);

  //void SimplePedNoiRaw();
  //void PedNoiRaw();
  //void FindClustersRaw(Int_t,Int_t);
  //void HitNtuplRaw(Int_t,Int_t);
  //void HitNtuplWithEtaRaw(Int_t,Int_t,Int_t);

};
#endif
